package comunity;

public class User {
	private String username;
	private Status status;
	private double lat, lon;

	public User(Status status, String username, double lat, double lon) {
		this.username = username;
		this.status = status;
		this.lat = lat;
		this.lon = lon;
	}

	public User(String status, String username, double lat, double lon) {
		this(User.parseString(status), username, lat, lon);
	}

	private static Status parseString(String status) {
		if (status.equals(Status.ONLINE.toString()))
			return Status.ONLINE;
		if(status.equals(Status.OFFLINE.toString()))
			return Status.OFFLINE;
		return Status.BUSY;
	}

	@Override
	public int hashCode() {
		return username.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof User))
			return false;
		User user = (User) obj;
		return username.equals(user.username);
	}

	public String getUsername() {
		return username;
	}

	public Status getStatus() {
		return status;
	}

	void setStatus(Status status) {
		this.status = status;
	}
	
	public GPSLocation getGPSLocation(){
		return new GPSLocation(this.lat, this.lon);
	}
	
	public void setLat(double lat) {
		this.lat = lat;
	}
	
	public void setLon(double lon) {
		this.lon = lon;
	}
}
